﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ShapeExer
{
    internal class Factory
    {
        //静态工厂方法
        public static IShape GetShape(int n)//得到形状
        {
            IShape shape = null;
            switch (n) {
                case 0:
                    Console.WriteLine("请输入该矩形的长和宽");
                    double x = double.Parse(Console.ReadLine());
                    double y = double.Parse(Console.ReadLine());
                    shape=new Rectangle(x, y);
                    break;
                case 1:
                    Console.WriteLine("请输入该正方形的边长");
                    double  b= double.Parse(Console.ReadLine());
                    shape = new Square(b);
                    break;
                case 2:
                    Console.WriteLine("请输入该三角形的三条边");
                    double o = double.Parse(Console.ReadLine());
                    double p = double.Parse(Console.ReadLine());
                    double q = double.Parse(Console.ReadLine());
                    shape = new Triangle(o, p, q);
                    break;
                default:
                    Console.WriteLine("输入不合法！");
                    break;
            }
            return shape;
        }

    }
}
